<?php
//数组array()
$car = array("benchi","baoma","kaidilake");
echo "i like " . $car[0] ." " . $car[1] . " and " . $car[2];

//在指定位置添加元素：
$car[3] = "Volvo";
echo "<br>";
echo $car[3];
echo PHP_EOL;

//获取元素的个数count()
$arrayLength = count($car);
echo $arrayLength;
echo "<br>";

//遍历数组:
echo "遍历数组\n";
for($x=0 ;$x<$arrayLength ;$x++){

    echo $car[$x];
    echo PHP_EOL;
}
echo "<br>";
//遍历关联数组foreach
$age = array("Peter"=>"11","Ben"=>"12","Joe"=>"13");
foreach ($age as $x=>$x_value)  //foreach($数组 as $键=>$值)
{
    echo $x . "今年" . $x_value;
    echo "<br>";
}

for ($i = 1 ;$i<10 ;$i++) {
    for ($j = 1 ;$j<=$i ;$j++) {
        echo strval($i) . "*" . strval($j) . "=" . strval($i*$j);
        echo PHP_EOL;
    }
    echo "<br>";
}

$cheng = [1,2,3,4,5,6,7,8,9];

foreach ($cheng as $k) {
    foreach ($cheng as $ke) {
        if ($ke <= $k) {
            echo strval($k) . "*" . strval($ke) . "=" . strval($k*$ke);
            echo PHP_EOL;
        }
    }
    echo "<br>";
}

//二维数组
$array = [
    'wanke' => "4255",
    "weixing" => "4051",
    "zhongde" => "3322"
];
unset($array['wanke']);

foreach ($array as $a_k) {
    print_r("输出数组的值：" . $a_k);
}

//isset 是如果存在就返回1 不存在什么也不返回
echo "!!!!!!!!!!!!!!!";
print_r(isset($array));

?>